package com.github.edu.repair.manager.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 故障描述
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-20
 */
@Entity
@Table(name = "t_bx_gzms")
public class TBxGzms implements Serializable {
    private Integer id;
    private Integer fwdl;
    private String fwfl;
    private String fwsm;
    private String bz;
    private Integer sfqy;
    private TBxFwdl bxFwdl;
    private String fwdlmc;

    @Id
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "fwdl")
    public Integer getFwdl() {
        return fwdl;
    }

    public void setFwdl(Integer fwdl) {
        this.fwdl = fwdl;
    }

    @Basic
    @Column(name = "fwfl")
    public String getFwfl() {
        return fwfl;
    }

    public void setFwfl(String fwfl) {
        this.fwfl = fwfl;
    }

    @Basic
    @Column(name = "fwsm")
    public String getFwsm() {
        return fwsm;
    }

    public void setFwsm(String fwsm) {
        this.fwsm = fwsm;
    }

    @Basic
    @Column(name = "bz")
    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    @Basic
    @Column(name = "sfqy")
    public Integer getSfqy() {
        return sfqy;
    }

    public void setSfqy(Integer sfqy) {
        this.sfqy = sfqy;
    }

    @ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name = "fwdl",referencedColumnName = "id",insertable = false,updatable = false)
    public TBxFwdl getBxFwdl() {
        return bxFwdl;
    }

    public void setBxFwdl(TBxFwdl bxFwdl) {
        if(null!=bxFwdl){
            this.fwdlmc=bxFwdl.getFwsm();
        }
        this.bxFwdl = bxFwdl;
    }

    @Transient
    public String getFwdlmc() {
        return fwdlmc;
    }

    public void setFwdlmc(String fwdlmc) {
        this.fwdlmc = fwdlmc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TBxGzms tBxGzms = (TBxGzms) o;
        return Objects.equals(id, tBxGzms.id) &&
                Objects.equals(fwdl, tBxGzms.fwdl) &&
                Objects.equals(fwfl, tBxGzms.fwfl) &&
                Objects.equals(fwsm, tBxGzms.fwsm) &&
                Objects.equals(bz, tBxGzms.bz) &&
                Objects.equals(sfqy, tBxGzms.sfqy);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, fwdl, fwfl, fwsm, bz, sfqy);
    }
}
